#ifndef Lexer_h
#define Lexer_h

#include <string>

#include <inttypes.h>

#include "Tokens.hpp"

class Lexer
{
    public:
    // own vars

    Token outToken;

    int line;
    int lastRow;
    char* lastNewline;
    char* tokenStart;

    // build in vars
    uint8_t cs;
    char* ts;
    char* te;
    uint8_t act;
    char* p;
    const char* pe;
    const char* eof;

    void init(const char* input, uint32_t len);

    Token nextToken();

    Token createToken(TokenType type)
    {
        outToken;
        outToken.line = line;
        outToken.row = lastRow;
        outToken.textStart = tokenStart;
        outToken.textEnd = p;
        outToken.type = type;

        tokenStart = p;
        lastRow = p-lastNewline;

        return outToken;
    }

    void skipToken()
    {
        tokenStart = p;
        lastRow = p-lastNewline+1;
    }

};

#endif
